/*
 * DatabaseDemoHostApplication.java
 *
 * Copyright (c) 2008-2009 Sun Microsystems, Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to
 * deal in the Software without restriction, including without limitation the
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 * sell copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 */

package org.sunspotworld;

import GUI.Bienvenido;
import GUI.Panel;
import GUI.Reportes;
import GUI.Tiempos;
import com.sun.spot.io.j2me.radiogram.*;

import com.sun.spot.peripheral.ota.OTACommandServer;
import com.sun.spot.util.IEEEAddress;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import javax.microedition.io.*;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import org.jfree.ui.RefineryUtilities;


/**
 * This application is the 'on Desktop' portion of the SendDataDemo. 
 * This host application collects sensor samples sent by the 'on SPOT'
 * portion running on neighboring SPOTs and graphs them in a window. 
 *   
 * @author Vipul Gupta
 * modified Ron Goldman
 */
public class HidroponiaHost {
    
    public static Usuario usuario = new Usuario();
    public static Bienvenido bienvenido = new Bienvenido();
    public static hiloCosecha hiloC = new hiloCosecha();
    public static HiloSensoresExternos hiloS = new HiloSensoresExternos();
    public static HiloSensoresInternos hiloE = new HiloSensoresInternos();
    public static Relojes dialesL = new Relojes(null,1,"");
    public static Relojes dialesT = new Relojes(null,2,"");
    public static Relojes dialesPH = new Relojes(null,3,"");
    public static Relojes dialesA = new Relojes(null,4,"");
    public static Relojes diales1 = new Relojes(null,5,"");
    public static Relojes diales2 = new Relojes(null,6,"");
    public static Relojes diales3 = new Relojes(null,7,"");
    public static Relojes diales4 = new Relojes(null,8,"");
    public static Reportes reportes = new Reportes();
    public static Cosecha cosecha = new Cosecha();
    public static int minuto = 1000 * 60;
    public static int dia = 1000 * 60 * 60 * 24;
    public static int estado = 0;
    
    
    public void run() throws ParseException{
        dialesL.pack();
        dialesT.pack();
        dialesPH.pack();
        dialesA.pack();
        diales1.pack();
        diales2.pack();
        diales3.pack();
        diales4.pack();
        bienvenido.regandoLabel.setVisible(false);
        bienvenido.setVisible(true);
        LoginDialog login = new LoginDialog(bienvenido);
        login.setVisible(true);
        RiegosReporte riegoR = new RiegosReporte("Riegos");
        SensoresExternos sensoresE = new SensoresExternos("Sensores Externos");
        SensoresInternos sensoresI = new SensoresInternos("Sensores Externos");
        riegoR.pack();
        RefineryUtilities.centerFrameOnScreen(riegoR);
        sensoresE.pack();
        RefineryUtilities.centerFrameOnScreen(sensoresE);
        sensoresI.pack();
        RefineryUtilities.centerFrameOnScreen(sensoresI);
        /*SimpleDateFormat sdf = new SimpleDateFormat("HH:mma");
    Date date1=sdf.parse("7:40AM");
    Date date2=sdf.parse("7:50AM");
    long date1InMilSec=date1.getTime();
    long date2InMilSec=date2.getTime();
    System.out.println("Average "+sdf.format((date1InMilSec+date2InMilSec)/2));*/
        
    }
    

    /**
     * Start up the host application.
     *
     * @param args any command line arguments
     */
    public static void main(String[] args) throws Exception {
        // register the application's name with the OTA Command server & start OTA running
        OTACommandServer.start("Hidroponia");
        HidroponiaHost app = new HidroponiaHost();
        app.run();
    }
}
